Skip to content

Conversation

@vtushar06
Copy link
Contributor

@vtushar06 vtushar06 commented Dec 7, 2025

What kind of change does this PR introduce?
This PR introduces centralized type definitions to eliminate 'any' type annotations across the codebase.

Issue Number:

Summary

This PR improves type safety by introducing a centralized type definition system (types/common.ts) that replaces scattered 'any' type usages across 26 files.

Key changes included:

  • Created types/common.ts with shared type definitions: Frontmatter, SectionType, NavLink, Author
  • Updated 24 page components to import and use the Frontmatter type instead of 'any'
  • Fixed DocTable.tsx to accept optional frontmatter properties with proper type guards and conditional rendering
  • Pages updated: all draft versions (05-07, 2019-09, 2020-12), implementers, learn, overview, specification, understanding-json-schema, ambassadors

Type Safety Improvements:

  • Ensures consistent frontmatter handling across all markdown-based pages
  • Eliminates implicit 'any' typing in static page generation
  • Provides IDE autocomplete and type checking for frontmatter properties

Does this PR introduce a breaking change?
No. This is a pure refactoring that improves type safety without changing functionality.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

  • Read, understood, and followed the contributing guidelines.
  • TypeScript compilation: 0 errors
  • Linting passes with no warnings
  • All 26 pages tested and verified

Copilot AI review requested due to automatic review settings December 7, 2025 03:14
@vtushar06 vtushar06 requested a review from a team as a code owner December 7, 2025 03:14
@github-project-automation github-project-automation bot moved this to Ready to review in PR - Triage Group Dec 7, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances type safety across the JSON Schema website by introducing a centralized type definition system that replaces 'any' type annotations with properly typed interfaces. A new types/common.ts file consolidates shared type definitions including Frontmatter, SectionType, NavLink, Author, and other reusable types.

Key changes:

  • Created types/common.ts with 10+ reusable type definitions for consistent typing across the application
  • Updated 26 page components to use the Frontmatter type instead of 'any', improving IDE support and compile-time type checking
  • Standardized the use of nullish coalescing operator (??) for more precise null/undefined handling in section context providers

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
types/common.ts New centralized type definition file with Frontmatter, SectionType, NavLink, Author, and other shared interfaces
pages/understanding-json-schema/reference/[slug].page.tsx Replaced 'any' types with Frontmatter and proper parameter types; improved null handling with ?? operator
pages/understanding-json-schema/index.page.tsx Removed unused parameters and changed blocks from any[] to string[]
pages/understanding-json-schema/[slug].page.tsx Added Frontmatter type import and replaced 'any' with proper types; standardized null handling
pages/specification/release-notes/index.page.tsx Introduced BlocksData interface and replaced 'any' with Frontmatter; added conditional rendering for optional body
pages/specification/migration/index.page.tsx Added typed interfaces for blocks and frontmatter; improved optional field handling
pages/specification/json-hyper-schema/index.page.tsx Extended Frontmatter with SpecificationFrontmatter; added conditional rendering for optional fields
pages/overview/sponsors/index.page.tsx Changed blocks type from any[] to string[]
pages/overview/code-of-conduct/index.page.tsx Removed unused parameters and improved type safety for blocks
pages/overview/[slug].page.tsx Replaced 'any' types with Frontmatter; improved optional chaining for navigation properties
pages/learn/getting-started-step-by-step/index.page.tsx Removed unused parameters; typed blocks as string[]
pages/learn/[slug].page.tsx Added proper types for frontmatter and content; standardized null handling
pages/implementers/index.page.tsx Cleaned up unused parameters and improved blocks typing
pages/implementers/[slug].page.tsx Replaced 'any' with Frontmatter type; standardized section context handling
pages/draft/2020-12/index.page.tsx Extended Frontmatter with DraftFrontmatter for draft-specific fields
pages/draft/2020-12/[slug].page.tsx Improved type safety with Frontmatter type and proper parameter typing
pages/draft/2019-09/index.page.tsx Added DraftFrontmatter and BlocksData interfaces for type safety
pages/draft/2019-09/[slug].page.tsx Replaced 'any' types with proper TypeScript types
pages/draft-07/index.page.tsx Introduced typed interfaces for draft frontmatter and blocks data
pages/draft-07/[slug].page.tsx Added Frontmatter type and improved null handling
pages/draft-06/index.page.tsx Added draft-specific type extensions and improved type safety
pages/draft-06/[slug].page.tsx Replaced 'any' with Frontmatter and standardized section handling
pages/draft-05/index.page.tsx Extended Frontmatter for draft-specific metadata fields
pages/ambassadors/index.page.tsx Changed ambassadorData from any to string type
pages/[slug].page.tsx Added type import and replaced 'any' with proper Frontmatter and string types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vtushar06 vtushar06 force-pushed the fix/remove-any-types-pr1-types-and-pages branch from 439866b to f8f90bc Compare December 7, 2025 03:25
@github-actions
Copy link

github-actions bot commented Dec 7, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
website ✅ Ready (View Log) Visit Preview 777879a

@codecov
Copy link

codecov bot commented Dec 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (2dd1d24) to head (777879a).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1973   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           30        30           
  Lines          633       644   +11     
  Branches       196       206   +10     
=========================================
+ Hits           633       644   +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vtushar06 vtushar06 changed the title fix: Remove 'any' types by centralizing type definitions fix(types): Remove 'any' types by centralizing type definitions (#1034) Dec 7, 2025
@vtushar06
Copy link
Contributor Author

hii @Utkarsh-123github @jagpreetrahi , can you have a look into this, so that we can move forward with if more changes if required.

Copy link
Contributor

@jagpreetrahi jagpreetrahi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @vtushar06 , hope doing well. You did a good job so far, I appreciate it. Everything looks good to me but I have commented out on the codebase which could be more better in term of preventing the writing the same things again and again. And also if possible pls don't avoids the Copilot review.
Thanks.

@Utkarsh-123github
Copy link
Member

Thanks @jagpreetrahi for the review🚀
Tushar, could you please address Jagpreet’s comments when you get a chance?

@vtushar06
Copy link
Contributor Author

Hii @jagpreetrahi, implemented changes as per suggestion can you look and guide me for next step

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 26 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@jagpreetrahi jagpreetrahi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Utkarsh-123github , this lgtm and approved from my side. Is there anything you want to look out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready to review

Development

Successfully merging this pull request may close these issues.

🐛 Bug: Search and remove any from codebase

3 participants